package com.metaapp.demo.view.activity

import android.content.Context
import android.widget.ImageView
import com.metaapp.demo.R
import com.metaapp.demo.bean.SearchDataBean
import com.metaapp.demo.custom.imageloader.ImageLoader
import com.metaapp.demo.custom.recyclerview.CommonAdapter
import com.metaapp.demo.custom.recyclerview.ViewHolder
import com.metaapp.demo.utils.ScreenUtil

/**
 * 检索页面适配器
 */
class SearchPicAdapter(context: Context, layoutId: Int) :
    CommonAdapter<SearchDataBean.ListBean>(context, layoutId) {
    override fun bindData(holder: ViewHolder, data: SearchDataBean.ListBean?, position: Int) {
        data?.let {
            //设置文本
            holder.setText(R.id.text_content, it.title)
            //加载图片
            ImageLoader.getInstance()
                .load(it.thumb)
                .with(mContext)
                .placeholder(R.drawable.yh_icon_default_pic_middle)
                .error(R.drawable.yh_icon_default_pic_middle)
                .roundCorner(ScreenUtil.dip2px(mContext, 7f))
                .into((holder.getView(R.id.image_content) as ImageView))
        }
    }
}